/*
 * Teknei 2014 - All rights reserved
 */
package com.teknei.acabus.core.entities;

import java.io.Serializable;

import javax.persistence.*;

import java.util.List;


/**
 * The persistent class for the "ROLES" database table.
 * @author Jorge Amaro
 * @version 1.0
 * @since 1.0
 */
@Entity
@Table(name="\"SITM_ROLES\"")
@NamedQuery(name="Role.findAll", query="SELECT r FROM Role r")
public class Role implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="ROLES_IDROLE_GENERATOR", sequenceName="\"ROLES_id_role_seq\"")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ROLES_IDROLE_GENERATOR")
	@Column(name="id_role")
	private Integer idRole;

	@Column(name="role_name")
	private String roleName;

	//bi-directional many-to-one association to NavigationChildRole
	@OneToMany(mappedBy="role")
	private List<NavigationChildRole> navigationChildRoles;

	//bi-directional many-to-one association to NavigationParentRole
	@OneToMany(mappedBy="role")
	private List<NavigationParentRole> navigationParentRoles;

	/**
	 * 
	 */
	public Role() {
	}

	/**
	 * @return
	 */
	public Integer getIdRole() {
		return this.idRole;
	}

	/**
	 * @param idRole
	 */
	public void setIdRole(Integer idRole) {
		this.idRole = idRole;
	}

	/**
	 * @return
	 */
	public String getRoleName() {
		return this.roleName;
	}

	/**
	 * @param roleName
	 */
	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	/**
	 * @return
	 */
	public List<NavigationChildRole> getNavigationChildRoles() {
		return this.navigationChildRoles;
	}

	/**
	 * @param navigationChildRoles
	 */
	public void setNavigationChildRoles(List<NavigationChildRole> navigationChildRoles) {
		this.navigationChildRoles = navigationChildRoles;
	}

	/**
	 * @param navigationChildRole
	 * @return
	 */
	public NavigationChildRole addNavigationChildRole(NavigationChildRole navigationChildRole) {
		getNavigationChildRoles().add(navigationChildRole);
		navigationChildRole.setRole(this);

		return navigationChildRole;
	}

	/**
	 * @param navigationChildRole
	 * @return
	 */
	public NavigationChildRole removeNavigationChildRole(NavigationChildRole navigationChildRole) {
		getNavigationChildRoles().remove(navigationChildRole);
		navigationChildRole.setRole(null);

		return navigationChildRole;
	}

	/**
	 * @return
	 */
	public List<NavigationParentRole> getNavigationParentRoles() {
		return this.navigationParentRoles;
	}

	/**
	 * @param navigationParentRoles
	 */
	public void setNavigationParentRoles(List<NavigationParentRole> navigationParentRoles) {
		this.navigationParentRoles = navigationParentRoles;
	}

	/**
	 * @param navigationParentRole
	 * @return
	 */
	public NavigationParentRole addNavigationParentRole(NavigationParentRole navigationParentRole) {
		getNavigationParentRoles().add(navigationParentRole);
		navigationParentRole.setRole(this);

		return navigationParentRole;
	}

	/**
	 * @param navigationParentRole
	 * @return
	 */
	public NavigationParentRole removeNavigationParentRole(NavigationParentRole navigationParentRole) {
		getNavigationParentRoles().remove(navigationParentRole);
		navigationParentRole.setRole(null);

		return navigationParentRole;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((idRole == null) ? 0 : idRole.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Role other = (Role) obj;
		if (idRole == null) {
			if (other.idRole != null)
				return false;
		} else if (!idRole.equals(other.idRole))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Role [idRole=" + idRole + ", roleName=" + roleName + "]";
	}
	
	

}